package com.sx.epidemic_system.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sx.epidemic_system.entity.MapValue2;
import com.sx.epidemic_system.entity.ResultVo;
import com.sx.epidemic_system.entity.Total;
import com.sx.epidemic_system.service.NewAddService;
import com.sx.epidemic_system.service.TotalService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

@Controller
public class TotalController {

    @Resource
    TotalService totalService;


    @ResponseBody
    @RequestMapping("/getTotalCount")
    public String getTotalCount(String province) {
        Total total = totalService.totalCount(province);
        int num = total.getTotalConfirm();

        return num + "";
    }

    @ResponseBody
    @RequestMapping("/getTotalForeignCount")
    public String getTotalForeignCount(String province) {
        Total total = totalService.totalForeignCount(province);
        int num = total.getTotalConfirm();

        return num + "";
    }

    @ResponseBody
    @RequestMapping("/getTotalCure")
    public String getTotalCure(String province) {
        Total total = totalService.totalCure(province);
        int num = total.getTotalConfirm();

        return num + "";
    }

    @ResponseBody
    @RequestMapping("/getTotalDead")
    public String getTotalDead(String province) {
        Total total = totalService.totalDead(province);
        int num = total.getTotalConfirm();

        return num + "";
    }

    @ResponseBody
    @RequestMapping("/getTotalList")
    public List<Integer> getTotalList(String province) {
        List<Integer> list = new ArrayList<>();
        Total total = totalService.totalCount(province);
        int num = total.getTotalConfirm();
        list.add(num);
        total = totalService.totalForeignCount(province);
        num = total.getTotalConfirm();
        list.add(num);
        total = totalService.totalCure(province);
        num = total.getTotalConfirm();
        list.add(num);
        total = totalService.totalDead(province);
        num = total.getTotalConfirm();
        list.add(num);
        return list;

    }

    @ResponseBody
    @RequestMapping("/getTableList")
    public ResultVo getTableList(Integer page , Integer limit ) {
        return totalService.tableList(page, limit);
    }


}
